import wsgiref.handlers

from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

from libs import deck

import os

class MainPage(webapp.RequestHandler):
    def get(self):
        path = os.path.join(os.path.dirname(__file__), '../view/tock/main.tpl')
        self.response.out.write(template.render(path, {}))
        
class GamePage(webapp.RequestHandler):
    def get(self, gameID):
        path = os.path.join(os.path.dirname(__file__), '../view/tock/game.tpl')
        self.response.out.write(template.render(path, {}))
        
class GameListPage(webapp.RequestHandler):
    def get(self):
        path = os.path.join(os.path.dirname(__file__), '../view/tock/list.tpl')
        self.response.out.write(template.render(path, {}))

class StandingsPage(webapp.RequestHandler):
    def get(self):
        path = os.path.join(os.path.dirname(__file__), '../view/tock/standings.tpl')
        self.response.out.write(template.render(path, {}))

def main():
    application = webapp.WSGIApplication([('/tock', MainPage),
                                          (r'/tock/games/(.*)', GamePage),
                                          ('/tock/list', GameListPage),
                                          ('/tock/standings', StandingsPage)],
                                         debug=True)
    wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
    main()